<?php
error_reporting(0);
require_once( 'DBConfig.php' );
session_start();
if ($_SESSION["adminusername"]=="")
{
    echo "Niste prijavljeni kao administrator";
    exit;
}
$link = mysql_connect($AdminHost, $AdminUser, $AdminPassword);
$aDB =mysql_select_db($AdminDatabase , $link);
if ($_POST['naslov']!="" and $_POST['blogtext']!="" and $_SESSION["adminusername"]!="")
{
    $naslov=$_POST['naslov'];
    $tekst=  $_POST['blogtext'];
    $aSQL1  = "insert into blog_poruke1 (id, datum, username, naslov, tekst, status, kategorija) values ('',now(),'ADMIN','$naslov','$tekst',' ',' ')";
    $aQResult1 = mysql_query($aSQL1) or die(mysql_error());
    echo "Sajam je uspesno dodat, uskoro ce biti vidljiv na sajtu<br><form><input type=\"button\" value=\"Zatvori stranicu\" onclick=\"self.close();\"></form>";
}
else
{
    echo "
    <html>
    <head>
    <title>Dodaj podatak Sajmovi</title>
 <script language=\"JavaScript\" type=\"text/javascript\" src=\"js/openwysiwyg/scripts/wysiwyg.js\"></script>
<script language=\"JavaScript\" type=\"text/javascript\" src=\"js/openwysiwyg/scripts/wysiwyg-settings.js\"></script> 
    </head>
    <body >
      <form name=\"dodajblog\" id=\"dodajblog\" action=\"blog_dodaj1.php\" method=\"post\">
      <font face=\"Arial\">Naslov:</font><input type=\"text\" name=\"naslov\" id=\"naslov\" size=\"56\" >
      <p style=\"margin-top: 0; margin-bottom: 0\"><font face=\"Arial\">Tekst:</font></p>
        <p style=\"margin-top: 0; margin-bottom: 0\">
      <textarea name=\"blogtext\" id=\"blogtext\" rows=\"8\" cols=\"40\">
      </textarea>
      </p>
        <p>
  <script language=\"javascript1.2\">
   // attach the editor to the textarea with the identifier 'textarea1'.
   WYSIWYG.attach('blogtext');
</script>    
      <input type=\"submit\" name=\"unesi\" id=\"unesi\" value=\"Potvrdi\">
      </p>
      </form>
      
      </body>
    </html>";
}
?>
